home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / wb_41e.zip / DDEGROUP.WB_ < prev    next >
Text File  |  1992-12-18  |  4KB  |  143 lines

  1. ; Set up useful variables
  2. crlf = StrCat(Num2Char(13), Num2Char(10))
  3. tab = Num2Char(9)
  4.  
  5.  
  6. ; Define dialog box format
  7. AddItemFormat=`WWWDLGED,4.0`
  8.  
  9. AddItemCaption=`Add Item`
  10. AddItemX=86
  11. AddItemY=30
  12. AddItemWidth=158
  13. AddItemHeight=211
  14. AddItemNumControls=7
  15.  
  16. AddItem01=`4,6,40,DEFAULT,STATICTEXT,DEFAULT,"&Program:"`
  17. AddItem02=`48,6,74,140,FILELISTBOX,prog,DEFAULT`
  18. AddItem03=`4,150,40,DEFAULT,STATICTEXT,DEFAULT,"&Description:"`
  19. AddItem04=`48,150,94,DEFAULT,EDITBOX,desc,""`
  20. AddItem05=`8,170,66,DEFAULT,CHECKBOX,runmin,"&Run minimized",1`
  21. AddItem06=`8,190,66,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  22. AddItem07=`84,190,66,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  23.  
  24.  
  25.  
  26.  
  27. ; See if anyone respondes to a "Progman" DDE request
  28. channel = DDEInitiate("Progman", "Progman")
  29. if channel !=0 then goto top      ;  Somebody did.  Goody.
  30.  
  31. ; Nobody home at Progman DDE request, so start program manager
  32. Run("progman.exe", "")
  33. channel = DDEInitiate("Progman", "Progman")
  34. If channel == 0 Then Message("DDE Error","Could not start Progman DDE")
  35.                 then exit
  36.  
  37.  
  38.  
  39.  
  40. :top
  41. attop = @TRUE
  42. action = TextSelect("DDE", "Show Groups/Items|Add Group|Delete Group|Add Item|Delete Item", "|")
  43. If action == "" Then Goto top
  44. attop = @FALSE
  45.  
  46. If action == "Add Group" Then Goto addgroup
  47. If action == "Delete Group" Then Goto delgroup
  48.  
  49. groups = DDERequest(channel, "Groups")
  50. groups = StrReplace(groups, crlf, tab)
  51.  
  52. :selgroup
  53. group = StrUpper(ItemSelect("Select a program group", groups, tab))
  54. If group == "" Then Goto selgroup
  55. rc = DDEExecute(channel, "[CreateGroup(%group%)]")
  56. If rc == "" Then errmsg="ShowGroup? DDE"
  57.             then Goto error
  58.  
  59. If action == "Add Item" Then Goto additem
  60. If action == "Delete Item" Then delflag=1
  61.                            Then Goto showdelitem
  62. if action == "Show Groups/Items" then delflag=0
  63.                                  then goto showdelitem
  64. Goto top
  65.  
  66. :addgroup
  67. group = AskLine("Add group", "Enter name of new group", "")
  68. If group == "" Then Goto addgroup
  69. rc = DDEExecute(channel, "[CreateGroup(%group%)]")
  70. If rc == "" Then errmsg="CreateGroup"
  71.             then Goto error
  72. Goto addgroup
  73.  
  74. :delgroup
  75. groups = DDERequest(channel, "Groups")
  76. groups = StrReplace(groups, crlf, tab)
  77. group = StrUpper(ItemSelect("Select a group to delete", groups, tab))
  78. If group == "" Then Goto delgroup
  79. ok = AskYesNo("Delete Group", "Really delete '%group%'?")
  80. If !(ok) Then Goto delgroup
  81. rc = DDEExecute(channel, "[DeleteGroup(%group%)]")
  82. If rc == "" Then errmsg="DeleteGroup"
  83.             then Goto error
  84. Goto delgroup
  85.  
  86. :additem
  87. prog = "*.*"
  88. desc = ""
  89. runmin = 0
  90. AddItemCaption = `Add Item to '%group%'`
  91. Dialog("AddItem")
  92. If !(FileExist(prog)) Then Goto additem
  93. prog = StrUpper(StrCat(DirGet(), prog))
  94. rc = DDEExecute(channel, "[AddItem(%prog%,%desc%,,,-1,-1,,,%runmin%)]")
  95. If rc == "" Then errmsg="AddItem"
  96.             then Goto error
  97. Goto additem
  98.  
  99.  
  100. :showdelitem
  101. entries = DDERequest(channel, group)
  102. If (entries == "***NACK***" || entries=="") Then Message(group, "Empty Group")
  103.                                             then Goto top
  104. entries = StrReplace(entries, crlf, tab)
  105. entries = ItemRemove(1, entries, tab)
  106. n = ItemCount(entries, tab)
  107. If n == 0 Then Message(group, "Empty group")
  108.           Then Goto top
  109.  
  110. items = ""
  111.  
  112. i = 0
  113. :dnextitem
  114. i = i + 1
  115. item = ItemExtract(i, entries, tab)
  116. comma = StrIndex(item, ",", 1, @FWDSCAN)
  117. item = StrSub(item, 2, comma - 3)
  118. items = StrCat(items, item, tab)
  119. If i < n Then Goto dnextitem
  120.  
  121. :delitem2
  122. if delflag==1 then delmsg="Select an item to delete from %group%"
  123.               else delmsg="Items in %group%"
  124. item = ItemSelect(delmsg, items, tab)
  125. if delflag==0 then goto selgroup
  126. If item == "" Then Goto delitem2
  127. ok = AskYesNo(item, "Really delete this item from %group%?")
  128. If !(ok) Then Goto delitem2
  129. DDEExecute(channel, "[DeleteItem(%item%)]")
  130. i = ItemLocate(item, items, tab)
  131. items = ItemRemove(i, items, tab)
  132. If ItemCount(items, tab) == 0 Then Message(group, "Empty group")
  133.                               Then Goto top
  134. Goto delitem2
  135.  
  136. :error
  137. if !IsDefined(errmsg) then errmsg="Unknown DDE"
  138. Message("DDE Error", "%errmsg% operation unsuccessful")
  139.  
  140. :cancel
  141. If attop == @FALSE Then Goto top
  142. If IsDefined(channel) Then DDETerminate(channel)
  143.